app.use(express.json()); // Keep this for other routes that might need JSON

app.post('/api/convert/:platform', upload.single('mdFile'), async (req, res) => {
    try {
        if (!req.file) {
            return res.status(400).send('Missing MD file upload');
        }
        
        const markdownContent = await fs.readFile(req.file.path, 'utf-8');
        await fs.unlink(req.file.path);

        // Replace the original destructuring with our file-based content
        const result = await convertMarkdown({
            markdown: markdownContent,
            markdownTheme: req.body.markdownTheme || 'normal',
            codeTheme: req.body.codeTheme || 'github'
        }, req.params.platform);

        res.set('Content-Type', 'text/html');
        res.send(result);
    } catch (error) {
        console.error('File processing error:', error);
        res.status(500).send('Internal server error');
    }
});
const fs = require('fs').promises;
const multer = require('multer');
const upload = multer({ dest: 'uploads/' });